from enum import Enum

from bct.tools.common.bct4.base_dto import JsonDTO


class Instance(Enum):
    CLOSE = 'close'


class QuoteDetail(JsonDTO):
    settle: str
    close: str

    def __init__(self, param: dict = {}):
        super().__init__()
        self.settle = param['settle']
        self.close = param['close']

    def to_dict(self):
        return {
            "settle": self.settle,
            "close": self.close,
        }


class QuoteDTO(JsonDTO):
    instance: Instance
    instrument_id: str
    # yyyy-mm-dd
    valuation_date: str
    quote: QuoteDetail

    def to_dict(self):
        return {
            "instance": self.instance.value,
            "instrumentId": self.instrument_id,
            "valuationDate": self.valuation_date,
            "quote": self.quote.to_dict()
        }
